import spring from "@/res/spring.js"
const note_url = "/note/"
function http(url){
    return note_url+url
}

//笔记基本操作

// 创建空笔记
function createNoteNull(param = {}){
    return spring({
        url: http('createNoteNull'),
        method: 'post',
        headers: {'Content-Type':'multipart/form-data'},
        data: param
    })
}

// 创建笔记
function createNote(param = {}){
    return spring({
        url: http('setJSON'),
        method: 'post',
        params: param,
        headers: {'Content-Type':'multipart/form-data'},
    })
}


function createCollect(param = {}){
    return spring({
        url: '/BlogStatus/createCollect',
        method: 'post',
        params: param
    })
}

// 得到最近编辑的笔记
function getRecentNote(param = {}) {
    return spring({
        url: http('getRecentNote'),
        method: 'post',
        params: param
    })
}

// 得到最近浏览的笔记
function getViewsNote(param = {}){
    return spring({
        url: http('getViewsNote'),
        method: 'post',
        params: param
    })
}

// 根据用户ID得到所有收藏夹
function selAllCollectByUuid(param = {}){
    return spring({
        url: '/BlogStatus/selAllCollectByUuid',
        method: 'post',
        params: param
    })
}

// 根据用户ID得到为收藏的笔记
function selAllNotCollectNote(){
    return spring({
        url: http('selNotCollectNote'),
        method: 'post',
        headers: {'Content-Type':'multipart/form-data'}
    })
}

// 得到该用户所有的课程笔记
function getNoteClassByUuid(){
    return spring({
        url: http('getNoteClassByUuid'),
        method: 'post',
        headers: {'Content-Type':'multipart/form-data'}
    })
}

// 查询该用户的课程笔记 -- 搜索
function selNoteClass(param = {}){
    return spring({
        url: http('selNoteClass'),
        method: 'post',
        headers: {'Content-Type':'multipart/form-data'},
        data: param
    })
}

// 获取收藏夹中的笔记
function getCollectNote(param = {}){
    return spring({
        url: '/BlogStatus/selCollectNote',
        method: 'post',
        params: param,
        headers: {'Content-Type':'multipart/form-data'},
    })
}

// 获取收藏夹中的文章
function getCollectPosts(param = {}){
    return spring({
        url: '/BlogStatus/selCollectPosts',
        method: 'post',
        params: param,
        headers: {'Content-Type':'multipart/form-data'}
    })
}

//根据笔记id得到笔记
function getNoteByNoteId(param = {}){
    return spring({
        url: http('getNoteByNoteId'),
        method: 'post',
        params: param
    })
}

// 保存内容
function saveNote(param = {}){
    return spring({
        url: http('UpdateNoteJsonByUuid'),
        method: 'post',
        params: param,
        headers: {'Content-Type': 'multipart/form-data'}
    })
}

export {
    createNoteNull,createCollect,getRecentNote,getViewsNote,selAllCollectByUuid,
    selAllNotCollectNote,getNoteClassByUuid,selNoteClass,getCollectNote,getCollectPosts,
    createNote,getNoteByNoteId,saveNote
}
